package com.lord.base.thread.pool;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import com.lord.base.thread.RunnableBase;

/**
 * 功能:java线程池
 */
public class TestThreadPool {

	public static void main(String[] args) {
		/*
		 corePoolSize 指的是保留的线程池大小。
		 maximumPoolSize 指的是线程池的最大大小。
		 keepAliveTime 指的是空闲线程结束的超时时间。
		 unit 是一个枚举，表示 keepAliveTime 的单位。
		 workQueue 表示存放任务的队列。 LinkedBlockingQueue的好处在于没有大小限制
		 */
		ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 10, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
		
		RunnableBase myRun = new RunnableBase();
		for (int i = 0; i < 11; i++) {
			//myRun.setList(list);
			Thread thread1 = new Thread(myRun, i + "号窗口");
			threadPoolExecutor.execute(thread1);
		}
		System.out.println("Thread start");
		threadPoolExecutor.shutdown();
		
		System.out.println("Running end!");
	}
}
